/**
 * A token used for representing comments.
 * @author James Stanier
 */
public class CommentToken implements Comparable {
	private SpecialNode comment;
	private Node parent;
	private int lineNumber;
	
	/**
	 * Constructor.
	 * @param c The node in the tree this comment is.
	 * @param p The parent of the comment node.
	 * @param l The line number it starts on in the source.
	 */
	public CommentToken(SpecialNode c, Node p, int l) {
		comment = c;
		parent = p;
		lineNumber = l;
	}
	
	/**
	 * Get the comment.
	 * @return The comment as a SpecialNode.
	 */
	public SpecialNode getComment() {
		return comment;
	}
	
	/**
	 * Get the parent of the comment.
	 * @return The parent as a Node.
	 */
	public Node getParent() {
		return parent;
	}
	
	/**
	 * Get the line number of the comment.
	 * @return The line number as an integer.
	 */
	public int getLineNumber() {
		return lineNumber;
	}
	
	/**
	 * Uses line number as a comparator.
	 */
	public int compareTo(Object s) throws ClassCastException {
		if(s instanceof CommentToken) {
			Integer a = this.getLineNumber();
			Integer b = ((CommentToken)s).getLineNumber();
			return a.compareTo(b);
		}
		else {
			throw new ClassCastException("Object is not of type Symbol.");
		}
	}
}
